package com.dhcc.android.base.utils.amap;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import com.iflytek.cloud.SpeechUtility;

/**
 * 弹出提示框，下载服务组件
 */
public class ApkInstaller {
	private Context context;

	public ApkInstaller(Context context) {
		this.context = context;
	}

	@SuppressWarnings("deprecation")
	public void install() {
		String url = SpeechUtility.getUtility().getComponentUrl();
		String assetsApk = "MobileSurvey.apk";
		processInstall(context, url, assetsApk);
		return;
	}

	/**
	 * 如果服务组件没有安装打开语音服务组件下载页面，进行下载后安装。
	 */
	private boolean processInstall(Context context, String url, String assetsApk) {
		// 直接下载方式
		Uri uri = Uri.parse(url);
		Intent it = new Intent(Intent.ACTION_VIEW, uri);
		context.startActivity(it);
		return true;
	}
}
